﻿@*@model IEnumerable<FinancePortal.Domain.Model.Client>*@
@{
    ViewBag.Title = "Index";
}
<div id="AreaTable" style="width: 780px; margin: auto;">
</div>
<script type="text/javascript">
    $(document).ready(function () {
        $('#AreaTable').jtable({
            title: 'Client List',
            paging: true,
            pageSize: 10,
            defaultSorting: 'Name ASC',
            sorting: true,
            columnResizable: true,
            columnSelectable: true,
            saveUserPreferences: true,
            actions: {
                listAction: '@Url.Action("/ClientList")'
                @if (Convert.ToBoolean(Session["IsAdmin"]))
                {
                    @:, deleteAction: '@Url.Action("/DeleteClient")',updateAction: '@Url.Action("/UpdateClient")',createAction: '@Url.Action("/CreateClient")'
                }
            },
            fields: {
                Id: {
                    key: true,
                    create: false,
                    edit: false,
                    list: false
                },
                Name: {
                    title: 'Name',
                    width: '20%',
                    inputClass: 'validate[required,max[100]]'
                },
                SOEID: {
                    title: 'SOEID',
                    width: '20%',
                    inputClass: 'validate[required,custom[soeid]]'
                },  
                Email: {
                    title: 'Email',
                    list: false,
                    inputClass: 'validate[required,custom[email]]'
                },
                AreaId: {
                    title: 'Area',
                    width: '20%',
                    options: '@Url.Action("/GetArea")'
                },
                Profile: {
                    title: 'Profile',
                    width: '20%',
                    options: { '3': 'Client' },
//                    create: false,
//                    edit: false,
                    list: false
                }
            },
            formCreated: function (event, data) {
                data.form.validationEngine();
            },
            formSubmitting: function (event, data) {
                return data.form.validationEngine('validate');
            },
            formClosed: function (event, data) {
                data.form.validationEngine('hide');
                data.form.validationEngine('detach');
            }
        });

        //Load person list from server
        $('#AreaTable').jtable('load');
    });

</script>
<script>
    $(document).ready(function () {
        $('#pageTitle').text('Clients');
    });
</script>
